package com.library.service.impl;

import com.library.entity.Book;
import com.library.mapper.BookMapper;
import com.library.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    
    @Autowired
    private BookMapper bookMapper;
    
    @Override
    public List<Book> findAllBooks() {
        return bookMapper.findAll();
    }
    
    @Override
    public Book findBookById(Integer id) {
        return bookMapper.findById(id);
    }
    
    @Override
    public boolean addBook(Book book) {
        return bookMapper.insert(book) > 0;
    }
    
    @Override
    public boolean updateBook(Book book) {
        return bookMapper.update(book) > 0;
    }
    
    @Override
    public boolean deleteBook(Integer id) {
        return bookMapper.delete(id) > 0;
    }
} 